package com.cike.sparkstudy.core.scala

import org.apache.spark.{SparkConf, SparkContext}

object WordCountLocal {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("LocalWordCount").setMaster("local");
    val sc = new SparkContext(conf);
    val lines = sc.textFile("D://DevelopeCodes//DemoData//sparktest.txt");
    val words = lines.flatMap(line => line.split("\t"))
    val pair = words.map(word=>(word,1))
    val wordCounts = pair.reduceByKey(_+_);

    wordCounts.foreach(wordCount => println(wordCount._1 + " appeared " + wordCount._2 + " times."))
  }

}
